package org.chungyan5.mnt.client;


import org.chungyan5.mnt.client.ui.MainDesktopView;
import org.chungyan5.mnt.client.ui.Status;

import com.google.gwt.core.client.EntryPoint;
import com.gwtmobile.ui.client.page.Page;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class Main implements EntryPoint {

    // create main core for MVP ======================================================
    //  create all essential objects for this Application: 
    public void onModuleLoad() {
        
        // implement ClientFactory ===================================================
        ClientFactoryImpl clientFactory = new ClientFactoryImpl();
        
	    // upgrade db, may be migration wrapper support by gwtmobile-persistence V1.1
        //	ALTER TABLE "main"."Item" ADD COLUMN "textCOntent" TEXT
	    //     CREATE TABLE IF NOT EXISTS `Item` (`textContent` TEXT, `name` TEXT, `_lastChange` BIGINT, `id` VARCHAR(32) PRIMARY KEY) null
	    //     mv the data fr. old table to new table
//        UpgradeDb upgradeDb = new UpgradeDb();
	    
        // Create main screen ===================================================
        MainDesktopView mainDesktopView = new MainDesktopView(clientFactory);
        Page.load(mainDesktopView);
	    
        // Auto. Sync ===================================================
        Sync sync = new Sync(clientFactory, mainDesktopView); 
        clientFactory.setSync(sync);
        
        // Status ===================================================
        Status status = new Status(mainDesktopView);
        clientFactory.setStatus(status);
    }
}